s = input('Print me staples. ')

def krug(string):
    s = ''
    for i in string:
        if i == '(':
            s += i
        elif i == ')':
            s += i
    if s.find('(') == -1 and s.find(')') == -1:
        return 0
    elif s.find('(') == -1:
        return -1
    elif s.find(')') == -1:
        return -1
    n = s.find('(')
    if n != 0:
        return -1
    k = 0
    for i in s:
        if i == '(':
            k += 1
        elif i == ')':
            k -= 1
    for i in s:
        if s.find('(') > s.rfind(')'):
            break
        if s.find('(') != -1 and s.rfind(')') != -1:
            s = s[s.find('(') + 1:s.rfind(')')]
    if s == '':
        flag = True
    else:
        flag = False
    if k == 0 and flag:
        return 1
    else:
        return -1


def kvad(string):
    s = ''
    for i in string:
        if i == '[':
            s += i
        elif i == ']':
            s += i
    if s.find('[') == -1 and s.find(']') == -1:
        return 0
    elif s.find('[') == -1:
        return -1
    elif s.find(']') == -1:
        return -1
    n = s.find('[')
    if n != 0:
        return -1
    k = 0
    for i in s:
        if i == '[':
            k += 1
        elif i == ']':
            k -= 1
    for i in s:
        if s.find('[') > s.rfind(']'):
            break
        if s.find('[') != -1 and s.rfind(']') != -1:
            s = s[s.find('[') + 1:s.rfind(']')]
    if s == '':
        flag = True
    else:
        flag = False
    if k == 0 and flag:
        return 1
    else:
        return -1


def figr(string):
    s = ''
    for i in string:
        if i == '{':
            s += i
        elif i == '}':
            s += i
    if s.find('{') == -1 and s.find('}') == -1:
        return 0
    elif s.find('{') == -1:
        return -1
    elif s.find('}') == -1:
        return -1
    n = s.find('{')
    if n != 0:
        return -1
    k = 0
    for i in s:
        if i == '{':
            k += 1
        elif i == '}':
            k -= 1
    for i in s:
        if s.find('{') > s.rfind('}'):
            break
        if s.find('{') != -1 and s.rfind('}') != -1:
            s = s[s.find('{') + 1:s.rfind('}')]
    if s == '':
        flag = True
    else:
        flag = False
    if k == 0 and flag:
        return 1
    else:
        return -1


def strl(string):
    s = ''
    for i in string:
        if i == '<':
            s += i
        elif i == '>':
            s += i
    if s.find('<') == -1 and s.find('>') == -1:
        return 0
    elif s.find('<') == -1:
        return -1
    elif s.find('>') == -1:
        return -1
    n = s.find('<')
    if n != 0:
        return -1
    k = 0
    for i in s:
        if i == '<':
            k += 1
        elif i == '>':
            k -= 1
    for i in s:
        if s.find('<') > s.rfind('>'):
            break
        if s.find('<') != -1 and s.rfind('>') != -1:
            s = s[s.find('<') + 1:s.rfind('>')]
    if s == '':
        flag = True
    else:
        flag = False
    if k == 0 and flag:
        return 1
    else:
        return -1


if krug(s) != -1 and kvad(s) != -1 and figr(s) != -1 and strl(s) != -1:
    print('True')
else:
    print('False')
